package view.contents;

import java.awt.Color;
import java.util.ArrayList;
import java.util.List;

import javax.swing.BoxLayout;

public class RecordList extends ContentBox {

	private List<RecordContainer> recordContainers;
	private int maxRecords = 0;
	private int spacing = 0;
	private int containerID;

	public RecordList(int maxRecords, int spacing, int container) {
		recordContainers = new ArrayList<RecordContainer>();
		this.maxRecords = maxRecords;
		this.spacing = spacing;
		this.containerID = container;
		this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
		this.setOpaque(false);
		this.setBackground(Color.blue);
		this.renew();
	}

	public void addRecord(RecordContainer r) {
		if (this.maxRecords <= this.recordContainers.size()) {
			return;
		}
		// r.setSize(r.getWidth(), this.getHeight()/this.maxRecords);
		this.recordContainers.add(r);
		this.renew();
	}

	public void renew() {
		this.removeAll();
		for (RecordContainer rc : this.recordContainers) {
			this.add(rc);
		}
		this.revalidate();
		this.repaint();
	}

	@Override
	public void cleanUp() {
		// TODO Auto-generated method stub
		this.removeAll();

	}

	@Override
	public void reinitialize() {
		// TODO Auto-generated method stub

	}

	@Override
	public void initialize() {
		// TODO Auto-generated method stub

	}

	@Override
	public boolean isSuccessfullyInitialized() {
		// TODO Auto-generated method stub
		return true;
	}

	@Override
	public String getContent() {
		// TODO Auto-generated method stub
		return null;
	}
}
